<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <title>QQ注册界面</title>
    <link rel="stylesheet" type="text/css" href="css/index.css"/>
</head>
<body>
    <div class="container">
        <div class="main">
            <div class="nav">
                    <div class="left-logo">
                        <div class="firstLogo">
                            <img src="img/QQ.png" alt="" />
                        </div>
                        <div class="qq">
                            <p>QQ</p>
                        </div>
                    </div>

                    <div class="rightNav">
                        <div class="set">
                            <img src="img/set.png" alt="" />
                        </div>

                        <div class="small">
                            <img src="img/small.png" alt="" />
                        </div>

                        <div class="close">
                            <img src="img/close.png" alt="" />
                        </div>
                    </div>
                </div>

            <div class="headImg">
                <div class="head">
                    <img src="img/IMG_3289.JPG" alt="" />
                </div>
            </div>

            <div class="content">
                <div class="login-content">
                    <form action="" method="">
                        <div class="form-content">
                            <div class="userImg">
                                <img src="img/text.png" alt="" />
                            </div>
                            <div class="userText">
                                <input type="text" id="username" name="name" placeholder="请输入您的用户名"/>
                            </div>
                        </div>
						
						<div class="form-content">
                            <div class="userImg">
                                <img src="img/my.png" alt="" />
                            </div>
                            <div class="userText">
                                <input type="text" id="loginname" name="username" placeholder="请输入您的昵称"/>
                            </div>
                        </div>
						
                         <div class="form-content">
                            <div class="userImg">
                                <img src="img/password.png" alt="" />
                            </div>
                            <div class="userText">
                                <input type="password" id="password" name="pass" placeholder="请输入您的密码"/>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
			
			<div class="chooseBtn">
            	<div class="registerBtn" style="margin-left: 90px;">
            		<button onclick="add()">注册</button>
            	</div>
			</div>
           
        </div>
    </div>
</body>

<script>
	
	 function add(){
	 	
	 	
	 	var username = $("#username").val()
		var password = $("#password").val()
		var loginname = $("#loginname").val()
		
		if (username == null || username == ""){
		   alert("请输入用户名")	
		   return 
		}
		if (password == null || password == ""){
		   alert("请输入密码")	
		   return 
		}
		if (loginname == null || loginname == ""){
		   alert("请输入昵称")	
		   return 
		}
		
		$.ajax({
			type:"get",
			url:"http://localhost:8080/add",
			data:{username:username,
				password:password,
				loginname:loginname
			},
			success:function(result){
				console.log(result)
				if (result == "1"){
					alert("恭喜注册成功")
					window.location = "login.html"
				}else{
					alert("注册失败")
				}
			}
			
		});	
		
		
	 	
	 	
	 }
	
	
</script>


<script src="js/jquery-1.11.1.min.js"></script>
</html>